package com.ruoyi.myplayer.controller;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.myplayer.mapper.PlayerSongMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.myplayer.domain.PlayerDaily;
import com.ruoyi.myplayer.service.IPlayerDailyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日推荐歌单Controller
 * 
 * @author lvyq
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/myplayer/daily")
public class PlayerDailyController extends BaseController
{
    @Resource
    private IPlayerDailyService playerDailyService;

    @Resource
    private PlayerSongMapper playerSongMapper;

    /**
     * 查询每日推荐歌单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlayerDaily playerDaily)
    {
        startPage();
        List<PlayerDaily> list = playerDailyService.selectPlayerDailyList(playerDaily);
        return getDataTable(list);
    }

    /**
     * 导出每日推荐歌单列表
     */
    @Log(title = "每日推荐歌单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlayerDaily playerDaily)
    {
        List<PlayerDaily> list = playerDailyService.selectPlayerDailyList(playerDaily);
        ExcelUtil<PlayerDaily> util = new ExcelUtil<PlayerDaily>(PlayerDaily.class);
        util.exportExcel(response, list, "每日推荐歌单数据");
    }

    /**
     * 获取每日推荐歌单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(playerDailyService.selectPlayerDailyById(id));
    }

    /**
     * 新增每日推荐歌单
     */
    @Log(title = "每日推荐歌单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlayerDaily playerDaily)
    {
        return toAjax(playerDailyService.insertPlayerDaily(playerDaily));
    }

    /**
     * 修改每日推荐歌单
     */
    @Log(title = "每日推荐歌单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlayerDaily playerDaily)
    {
        return toAjax(playerDailyService.updatePlayerDaily(playerDaily));
    }

    /**
     * 删除每日推荐歌单
     */
    @Log(title = "每日推荐歌单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(playerDailyService.deletePlayerDailyByIds(ids));
    }

    /**
     * @description 获取每日推荐 -30首
     * @author lvyq
     * @throws
     * @return AjaxResult
     * @time 2025-04-07 14:14
     */
    @GetMapping("/getDaily")
    public AjaxResult getDaily(){
        List<Map<String,Object>> result = playerDailyService.getDailyLst();
        return AjaxResult.success(result);
    }


    /**
     * @description 热门单曲
     * @author lvyq
     * @return AjaxResult
     * @time 2025-04-08 17:15
     */
    @GetMapping("/getHeatSong")
    public AjaxResult getHeatSong(){
        List<Map<String,Object>> result = playerDailyService.getHeatSong();
        return AjaxResult.success(result);
    }
}
